
/***************************************************************************
 *   sakcab 
 *                                                                         *
 *   Copyright (C) 2010 by kuerant                                         *
 *                         <kuerant@gmail.com>                             *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This library is distributed in the hope that it will be usefull, but  *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      *
 *   Library General Public License for more details.                      *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; if not, write to the Free Software   *
 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston,                *
 *   MA 02111-1307, USA                                                    *
 ***************************************************************************/


#ifndef	__KC_SAKCAB_STORE_HPP_2010__
#define	__KC_SAKCAB_STORE_HPP_2010__

#include <stdio.h>
#include <sys/types.h>
#include <string>
#include <vector>

namespace	sakcab	{

/// Store Interface
class	Store
{

public	:

	virtual int		insert( const std::string& kpin,
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		insertAppend( const std::string& kpin,
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		insertIgnore( const std::string& kpin,
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		find( const std::string& kpin,
                          const std::string& key, 
						       std::string& buf ) = 0;

	virtual int		find( const std::string& kpin,
                          const std::string& key, 
						        std::vector< std::string >& all_data,
								u_int32_t	limit = 0 ) = 0;

	virtual int		erase( const std::string& kpin,
                           const std::string& key ) = 0;

public	:

	virtual int		insert( const std::string& table,
                            const std::string& kpin,    
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		insertAppend( const std::string& table,
                            const std::string& kpin,    
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		insertIgnore( const std::string& table,
                            const std::string& kpin,    
                            const std::string& key,    
						    const std::string& data ) = 0;

	virtual int		find( const std::string& table,
                          const std::string& kpin,    
                          const std::string& key, 
						       std::string& buf ) = 0;

	virtual int		find( const std::string& table,
                          const std::string& kpin,    
                          const std::string& key, 
						        std::vector< std::string >& all_data,
								u_int32_t	limit = 0 ) = 0;

	virtual int		erase( const std::string& table,
                           const std::string& kpin,    
                           const std::string& key ) = 0;

public	:

	virtual int		insertAppend( const std::vector< std::string >& kpin,
								  const std::vector< std::string >& key,    
								  const std::vector< std::string >& data ) = 0;

	virtual int		insertAppend( const std::vector< std::string >& table,
								  const std::vector< std::string >& kpin,    
								  const std::vector< std::string >& key,    
								  const std::vector< std::string >& data ) = 0;

public	:

	virtual	int		slim( void ) = 0;

public	:
	virtual ~Store() {};

};	// class Store


class	StoreManager
{
public	:

	StoreManager( const char* ini_filename, const char* ini_section );

	~StoreManager();

public	:
	Store*	getStore() { return _store_p; }

private	:
	Store*	_store_p;
};	// class StoreManager

}	// namespace sakcab


#endif	// __KC_SAKCAB_STORE_HPP_2010__

